/*
 * @(#)DmsDocument.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.dms.bean;

import java.sql.Timestamp;
import java.util.List;

import com.dcivision.framework.Utility;
import com.dcivision.framework.bean.AbstractBaseObject;

/**
  DmsDocument.java

  This class is the serializable bean reflecting business logic uses.

    @author           Zoe Shum
    @company          DCIVision Limited
    @creation date    18/08/2003
    @version          $Revision: 1.42.2.2 $
*/

public class DmsDocument extends AbstractBaseObject {

  public static final String REVISION = "$Revision: 1.42.2.2 $";


  static final long serialVersionUID = 530451224573126163L;

  public static final String PERSONAL_ROOT_FOLDER_NAME = "PERSONAL";
  
  /** Indicate this dmsDocument type is for folder purpose */
  public static final String FOLDER_TYPE = "Z";

  /** Indicate this dmsDocument type is for dmsDocument purpose */
  public static final String DOCUMENT_TYPE = "D";

  /** Indicate this dmsDocument type is for compound purpose */
  public static final String COMPOUND_DOC_TYPE = "C";

  /** Indicate this dmsDocument type ia an relationship; Please refer to the SYSTEM_OPTION_DOCUMENT_RELATIONSHIP */
  public static final String DOCUMENT_LINK = "L";
  public static final String DOCUMENT_EXTRACTED_SUMMARY = "S";
  public static final String DOCUMENT_ANNOTATED_VERSION = "A";
  public static final String DOCUMENT_IN_OUT = "I";
  /**  -- END-- **/
  
  /** Indicate this dmsDocument type is for paper document */
  public static final String PAPER_DOC_TYPE="H";
  
  /** Indicate this dmsDocument type is for email document */
  public static final String EMAIL_DOC_TYPE="E";
  
  public static final String ORIGINSLITY_EMAIL_TYPE = "O";
  
  public static final String TIF_ANNOTATION_TYPE = "T";
  
  /** Indicate this dmsDocument type is for workflow document */
  public static final String FLOW_DOC_TYPE="W";
  
  /** Indicate this dmsDocument type is for form document */
  public static final String FORM_DOC_TYPE="F";

  /** Private variables */
  private String documentName = null;
  private String documentType = null;
  private Integer parentID = null;
  private Integer rootID = null;
  private String priority = null;
  private String createType = null;
  private Timestamp effectiveStartDate = null;
  private Timestamp effectiveEndDate = null;
  private Integer reminderAmount = null;
  private String reminderType = null;
  private String[] notificationWay = null;
  private Integer ownerID = null;
  private String realDocumentName = null;

  /** Version Detail on target document */
  private Integer versionID = null;
  private String versionNumber = null;
  private String versionLabel = null;
  private Integer versionParentID = null;
  private String referenceNo = null;
  private String description = null;
  private Integer itemSize = null;
  private String itemStatus = null;
  private Integer contentID = null;
  
  // for full text used when checkin
  private String versionFileName = null ;

  /** Document Detail on target document */
  private List documentDetails = null;
  private List udfDetailList = null;
  private Integer userDefinedFieldID = null;

  private Integer checkoutID = null;
  private Integer alertEditID = null;
  private Integer alertInviteID = null;
  private String userDef1 = null;
  private String userDef2 = null;
  private String userDef3 = null;
  private String userDef4 = null;
  private String userDef5 = null;
  private String userDef6 = null;
  private String userDef7 = null;
  private String userDef8 = null;
  private String userDef9 = null;
  private String userDef10 = null;
  private int noOfVersion=0;

  /* Full text string */
  private String fullText = null;

  private String curFunctionCode = null;
  private String outerCriteria = null;
  private String[] outerCriteriaValue = null;

  // For audit trail
  private Timestamp accessDate = null;
  private String accessType = null; //action that have done with the object
  private Integer actionUserID = null;

  private boolean bCreatePhysicalFile = false;
  private boolean bScanDocumentForFullText = false;
  private boolean hasRelationship = false;
  
  private List dmsVersionList = null;
  
  private Timestamp checkoutDate = null;
  private Timestamp checkinDate=null;

  private String extRef ="";
  
  /*Document relationship*/
  /* variable:relationship type
     This private variable is used for the document relationship page for indicate its
     relationship of other document
   */
 // private String relationshipType = null;
  /* variable:relationshipDirection
     This private variable is used for the document relationship page for indicate
     the direction of relationship to other document, it can be "DIRECT" or "INDIRECT"
   */
 // private String relationshipDirection = null;

  public DmsDocument() {
    super();
  }

  public String getDocumentName() {
    return(this.documentName);
  }

  public void setDocumentName(String documentName) {
    this.documentName = documentName;
  }
  
  public String getRealDocumentName() {
    return(this.realDocumentName);
  }

  public void setRealDocumentName(String realDocumentName) {
    this.realDocumentName = realDocumentName;
  }

  public String getDocumentType() {
    return(this.documentType);
  }

  public void setDocumentType(String documentType) {
    this.documentType = documentType;
  }

  public Integer getParentID() {
    return(this.parentID);
  }

  public void setParentID(Integer parentID) {
    this.parentID = parentID;
  }

  public Integer getRootID() {
    return(this.rootID);
  }

  public void setRootID(Integer rootID) {
    this.rootID = rootID;
  }

  public String getPriority() {
    return(this.priority);
  }

  public void setPriority(String priority) {
    this.priority = priority;
  }

  public String getCreateType() {
    return(this.createType);
  }

  public void setCreateType(String createType) {
    this.createType = createType;
  }

  public Timestamp getEffectiveStartDate() {
    return(this.effectiveStartDate);
  }

  public void setEffectiveStartDate(Timestamp effectiveStartDate) {
    this.effectiveStartDate = effectiveStartDate;
  }

  public Timestamp getEffectiveEndDate() {
    return(this.effectiveEndDate);
  }

  public void setEffectiveEndDate(Timestamp effectiveEndDate) {
    this.effectiveEndDate = effectiveEndDate;
  }

  public Integer getReminderAmount() {
    return(this.reminderAmount);
  }

  public void setReminderAmount(Integer reminderAmount) {
    this.reminderAmount = reminderAmount;
  }

  public String getReminderType() {
    return(this.reminderType);
  }

  public void setReminderType(String reminderType) {
    this.reminderType = reminderType;
  }

  public String[] getNotificationWay() {
    return (this.notificationWay);
  }

  public void setNotificationWay(String[] notificationWay){
    this.notificationWay = notificationWay;
  }

  public Integer getOwnerID() {
    return(this.ownerID);
  }

  public void setOwnerID(Integer ownerID) {
    this.ownerID = ownerID;
  }

  public Integer getVersionID() {
    return(this.versionID);
  }

  public void setVersionID(Integer versionID) {
    this.versionID = versionID;
  }

  public String getVersionNumber() {
    return(this.versionNumber);
  }

  public void setVersionNumber(String versionNumber) {
    this.versionNumber = versionNumber;
  }

  public String getVersionLabel() {
    return(this.versionLabel);
  }

  public void setVersionLabel(String versionLabel) {
    this.versionLabel = versionLabel;
  }

  public Integer getVersionParentID() {
    return(this.versionParentID);
  }

  public void setVersionParentID(Integer versionParentID) {
    this.versionParentID = versionParentID;
  }

  public String getReferenceNo() {
    return(this.referenceNo);
  }

  public void setReferenceNo(String referenceNo) {
    this.referenceNo = referenceNo;
  }

  public String getDescription() {
    return(this.description);
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public Integer getItemSize() {
    return(this.itemSize);
  }

  public void setItemSize(Integer itemSize) {
    this.itemSize = itemSize;
  }

  public String getItemStatus() {
    return(this.itemStatus);
  }

  public void setItemStatus(String itemStatus) {
    this.itemStatus = itemStatus;
  }

  public Integer getContentID() {
    return(this.contentID);
  }

  public void setContentID(Integer contentID) {
    this.contentID = contentID;
  }

  public void setDocumentDetails(List documentDetails) {
    this.documentDetails = documentDetails;
  }

  public List getDocumentDetails() {
    return documentDetails;
  }

  public List getUdfDetailList() {
    return(this.udfDetailList);
  }

  public void setUdfDetailList(List udfDetailList) {
    this.udfDetailList = udfDetailList;
  }

  public Integer getUserDefinedFieldID() {
    return(this.userDefinedFieldID);
  }

  public void setUserDefinedFieldID(Integer userDefinedFieldID) {
    this.userDefinedFieldID = userDefinedFieldID;
  }

  public Integer getCheckoutID() {
    return(this.checkoutID);
  }

  public void setCheckoutID(Integer checkoutID) {
    this.checkoutID = checkoutID;
  }

  public Integer getAlertEditID() {
    return(this.alertEditID);
  }

  public void setAlertEditID(Integer alertEditID) {
    this.alertEditID = alertEditID;
  }

  public Integer getAlertInviteID() {
    return(this.alertInviteID);
  }

  public void setAlertInviteID(Integer alertInviteID) {
    this.alertInviteID = alertInviteID;
  }

  public String getUserDef1() {
    return(this.userDef1);
  }

  public void setUserDef1(String userDef1) {
    this.userDef1 = userDef1;
  }

  public String getUserDef2() {
    return(this.userDef2);
  }

  public void setUserDef2(String userDef2) {
    this.userDef2 = userDef2;
  }

  public String getUserDef3() {
    return(this.userDef3);
  }

  public void setUserDef3(String userDef3) {
    this.userDef3 = userDef3;
  }

  public String getUserDef4() {
    return(this.userDef4);
  }

  public void setUserDef4(String userDef4) {
    this.userDef4 = userDef4;
  }

  public String getUserDef5() {
    return(this.userDef5);
  }

  public void setUserDef5(String userDef5) {
    this.userDef5 = userDef5;
  }

  public String getUserDef6() {
    return(this.userDef6);
  }

  public void setUserDef6(String userDef6) {
    this.userDef6 = userDef6;
  }

  public String getUserDef7() {
    return(this.userDef7);
  }

  public void setUserDef7(String userDef7) {
    this.userDef7 = userDef7;
  }

  public String getUserDef8() {
    return(this.userDef8);
  }

  public void setUserDef8(String userDef8) {
    this.userDef8 = userDef8;
  }

  public String getUserDef9() {
    return(this.userDef9);
  }

  public void setUserDef9(String userDef9) {
    this.userDef9 = userDef9;
  }

  public String getUserDef10() {
    return(this.userDef10);
  }

  public void setUserDef10(String userDef10) {
    this.userDef10 = userDef10;
  }

  public String getFullText() {
    return(this.fullText);
  }

  public void setFullText(String fullText) {
    this.fullText = fullText;
  }

  public void setCurFunctionCode(String curFunctionCode) {
    this.curFunctionCode = curFunctionCode;
  }

  public String getCurFunctionCode() {
    return curFunctionCode;
  }

  public String getOuterCriteria() {
    return outerCriteria;
  }

  public void setOuterCriteria(String outerCriteria) {
    this.outerCriteria = outerCriteria;
  }

  public String[] getOuterCriteriaValue() {
    return this.outerCriteriaValue;
  }

  public void setOuterCriteriaValue(String[] outerCriteriaValue) {
    this.outerCriteriaValue = outerCriteriaValue;
  }

  public String getAccessType() {
    return (this.accessType);
  }

  public void setAccessType(String accessType) {
    this.accessType = accessType;
  }

  public Timestamp getAccessDate() {
    return (this.accessDate);
  }

  public void setAccessDate(Timestamp accessDate) {
    this.accessDate = accessDate;
  }

  public Integer getActionUserID() {
    return this.actionUserID;
  }

  public void setActionUserID(Integer actionUserID) {
    this.actionUserID = actionUserID;
  }

  public int getNoOfVersion() {
   return this.noOfVersion;
 }

 public void setNoOfVersion(int noOfVersion) {
   this.noOfVersion = noOfVersion;
 }

 public void setCreatePhysicalFile(boolean createPhysicalFile) {
   this.bCreatePhysicalFile = createPhysicalFile;
 }

 public boolean getCreatePhysicalFile() {
   return this.bCreatePhysicalFile;
 }

 public void setScanDocumentForFullText(boolean scanDocumentForFullText){
   this.bScanDocumentForFullText = scanDocumentForFullText;
 }

 public boolean getScanDocumentForFullText() {
   return this.bScanDocumentForFullText;
 }
 
 public void setHasRelationship(boolean hasRelationship){
   this.hasRelationship=hasRelationship;
 }
 
 public boolean getHasRelationship(){
   return this.hasRelationship;
 }


 /**
   * Check whether the document/folder is expired or not.
   *
   * @return  Whether the document/folder is expired or not.
   */
  public boolean isExpired() {
    java.sql.Timestamp nowTime = Utility.getCurrentTimestamp();
    Timestamp oneDayBeforeCurrTime = Utility.addDay(nowTime, -1);

    if (this.getEffectiveStartDate()==null && this.getEffectiveEndDate()==null) {
      return(false);
    }

    if ((this.getEffectiveStartDate()==null || this.getEffectiveStartDate().equals(nowTime) || this.getEffectiveStartDate().before(nowTime))
      && (this.getEffectiveEndDate()==null || this.getEffectiveEndDate().equals(nowTime) || this.getEffectiveEndDate().after(oneDayBeforeCurrTime))) {
      return (false);
    }
    
  

    return(true);
  }
  
  public void setDmsVersionList(List dmsVersionList){
  	  this.dmsVersionList = dmsVersionList;
  }
  
  public List getDmsVersionList (){
  	  return this.dmsVersionList;
  }
  
  public String getVersionFileName(){
    return this.versionFileName;
  }
  
  public void setVersionFileName(String versionFileName){
    this.versionFileName=versionFileName;
  }
  
  public Timestamp getCheckoutDate(){
  	return this.checkoutDate;
  }
  
  public void setCheckoutDate(Timestamp checkoutDate){
  	this.checkoutDate=checkoutDate;
  }
  
  public Timestamp getCheckinDate(){
  	return this.checkinDate;
  }
  
  public void setCheckinDate(Timestamp checkinDate){
  	this.checkinDate=checkinDate;
  }

  public String getExtRef(){
    return this.extRef;
  }
  
  public void setExtRef(String extRef){
    this.extRef=extRef;
  }  
  
  
  
}
